home *** CD-ROM | disk | FTP | other *** search
/ QuickTime for the Web (2nd Edition) / QuickTime for the Web (2nd Edition).iso / pc / Demos / Mac / Matthew's Behaviors / Matthew'sMotionƒ / edgeSpin < prev    next >
Encoding:
INI File  |  2001-09-10  |  1.8 KB  |  45 lines

  1. [Name]
  2. EdgeSpin - From Matthew's Motion Suite.
  3. By Matthew Peterson, matthew@pinoko.berkeley.edu
  4.  
  5. [Description]
  6. 2-19-2000
  7. Drop this on a sprite, and it will spin in 3D
  8.  
  9. [Parameters]
  10.  
  11. [Frame loaded]
  12. Spritevars  MP_flipangle MP_flipheight MP_flipanglestep MP_boxheight MP_scx MP_scy
  13.  
  14. MP_flipanglestep = 180/17 //Use a divisor of 180, but not 90.
  15. // if we rotate by 90, we won't be able to see the sprite because
  16. //it is being viewed along the edge.
  17. MP_scx = spriteofid($thisspriteid).secondcornerx //Setup the edge of the sprite
  18. MP_scy = spriteofid($thisspriteid).secondcornery
  19. //remember how tall the sprite is:
  20. MP_boxheight = spriteofid($thisspriteid).boundsbottom - spriteofid($thisspriteid).boundstop
  21. [Idle]
  22. SpriteVars MP_flipangle flipheight MP_flipanglestep MP_boxheight MP_scx MP_scy
  23. //EdgeSpin By Matthew Peterson
  24. // This behavior gives the illusion of 3D by
  25. // flipping the sprite along its edge. It flips
  26. // over and over in one direction, then hits
  27. // the border of the track and returns in the
  28. // other direction.  Perspective is calculated
  29. // which is unusual since it requires sine and
  30. // cosine. This is calculated by rotating the
  31. // sprite and taking the ratio of hight and
  32. // width. It is a subtle and fast calcuation.
  33. MP_flipangle = MP_flipangle + MP_flipanglestep
  34. IF(MP_flipangle <= 0)// Stay within 720 degrees.
  35.     MP_flipangle = MP_flipangle + 360
  36. ELSEIF(MP_flipangle >= 720)
  37.     MP_flipangle = MP_flipangle rem 360
  38. ENDIF
  39. ResetMatrix
  40.  
  41. Rotate(MP_flipangle)//Rotate in order to make trig calculations:
  42. flipheight = (SecondCornerY - FirstCornerY) * 0.2
  43. Stretch(FirstCornerX,SecondCornerY - flipheight,SecondCornerX, SecondCornerY, SecondCornerX,SecondCornerY + MP_boxheight,FirstCornerX,SecondCornerY + MP_boxheight + flipheight)
  44. MoveBy(MP_scx- SecondCornerX,MP_scy - SecondCornerY)
  45.